package com.imon.web.codesphere.resources;

import java.util.Collection;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.stereotype.Component;

import com.imon.web.codesphere.data.RepositoryInfo;

@Path("/repos")
@Component
public class RepositoryResource extends ResourceBase {
	private static final Log LOG = LogFactory.getLog(RepositoryResource.class);

	@GET
	@Produces(MediaType.APPLICATION_JSON)
	public Response getAllRepositories() {
		LOG.debug("getAllRepositories()");

		final Collection<RepositoryInfo> allRepos = getDatabase().loadAll(RepositoryInfo.class);
		return Response.ok(getJsonParser().getJson(allRepos)).build();
	}
}
